<template>
    <div class="center-box">
        <!--  首行 -->
        <div class="center-middle">
            <div class="shang-top">
                <span style="display: inline-block;float: left;padding-left: 20px;">用户管理</span>
                <div style="display: inline-block;float: right;padding-right: 20px;">
                    <button style="background-color: #fff;margin-right: 15px;border: 1px solid #eee;height: 30px; line-height: 30px; width: 72px;">
                        <i class="el-icon-refresh"></i>&nbsp&nbsp刷新
                    </button>
                </div>
            </div>
            <!--表格头部工具栏-->
            <div class="center-table">
                <div class="center-table-one">
                <span style="display: inline-block;float: left;">
                    <i class="el-icon-s-unfold"></i>数据列表
                </span>
                </div>
            </div>
            <!--  实现表格 -->
            <div class="center-table-two">
                <el-table
                        :model="form"
                        :data="tableData.slice((currentPage - 1) * pagesize,currentPage * pagesize)"
                        border
                        type="selection"
                        @selection-change="handleSelectionChange">
                    <el-table-column
                            type="selection"
                            align="center">
                    </el-table-column>
                    <el-table-column prop="deptId" label="部门名称" align="center"></el-table-column>
                    <el-table-column prop="deptName" label="用户名称" align="center"></el-table-column>
                    <el-table-column prop="trueName" label="名字" align="center"></el-table-column>
                    <el-table-column
                            fixed="right"
                            label="操作"
                            width="200">
                        <template slot-scope="scope">
                            <template>
                                <el-button type="text" @click="ck(scope.row)" class="btn">查看</el-button>
                            </template>
                        </template>
                    </el-table-column>
                </el-table>
                <!-- 对话框-->
                <el-dialog
                        width="80%"
                        title="用户详情"
                        :visible.sync="dialogFormVisible01"
                        append-to-body>
                    <el-row>
                        <el-form :label-position="labelPosition01" label-width="300px" :model="forms">
                            <el-col :span="6">
                                <el-form-item label="用户账号:" :label-width="formInter">
                                    <el-input v-model="forms.deptId"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="用户名称:" :label-width="formInter">
                                    <el-input v-model="forms.deptName"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="用户学号" :label-width="formInter">
                                    <el-input v-model="forms.trueName"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-form>
                    </el-row>
                </el-dialog>
                <!--分页-->
                <div class="page-box" style="float: right;">
                    <el-pagination
                            @size-change="handleSizeChange"
                            @current-change="handleCurrentChange"
                            :current-page="currentPage"
                            :page-sizes="[1,2,3,4,5,6,7,8,9,10]"
                            :page-size="pagesize"
                            layout="total, sizes, prev, pager, next, jumper"
                            :total="tableData.length">
                    </el-pagination>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        name: "Teacher",
        data(){
            return{
                dialogFormVisible01:false,
                labelPosition01:"top",
                forms:{
                    deptId:'',
                    deptName:"",
                    trueName:""

                },
                form:{
                    registerDate:"",
                    registerIp:"",
                    status:"",
                    region:""
                },
                //分页
                currentPage:1,
                currentIndex:" ",
                pagesize:2,
                //table组件
                tableData: [],
                tableData3:[],
                //弹出框
                formInter:'1000px',
                //复选框
                multipleSelection: []
            }
        },
        //实现表格中的全查
        mounted(){
            //表中的全查
            this.getAll();
        },
        methods: {
            //分页
            handleSizeChange(val) {
                this.pagesize = val;
                console.log('每页 ${val} 条');
            },
            handleCurrentChange(val) {
                this.currentPage = val
            },
            //全查
            getAll() {
                this.$http.post('/dept/getdept').then(res => {
                    this.tableData = res.data;
                })
            },
            //复选框
            handleSelectionChange(val) {
                this.multipleSelection = val;
            },
            ck(item){
                this.dialogFormVisible01 = true
                this.forms = {
                        deptId:item.deptId,
                        deptName:item.deptName,
                        trueName:item.trueName
                }
            }
        }
    }
</script>

<style long="less" scoped>
    *{
        padding: 0;
        margin: 0;
    }
    .center-box{
        width: 1500px;
    }
    .shang-top,.shang-middle{
        margin-top: 2px;
        margin-bottom: 5px;
        width: 100%;
        background: #F3F3F3;
        height: 45px;
        line-height: 45px;
        float: right;
    }
    .center-table-one{
        width: 100%;
        float: right;
        background: #F3F3F3;
        height: 45px;
    }
    .center-table-one span{
        height: 45px;
        line-height: 45px;
        padding-left: 20px;
    }
    .center-table-one div{
        padding-right: 15px;
    }
    .center-table-two{
        width: 100%;
    }
    .center-tree-one{
        float: left;
        background-color: #F2F2F2;
        width: 300px;
        height: 45px;
        line-height: 45px;
        padding-left: 15px;
    }
</style>
